﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Backend.Data.Entities;

namespace Backend.Data.Mappings
{
    class GeoReferenciaOrganigramaMap : EntityTypeConfiguration<GeoReferenciaOrganigrama>
    {
        public GeoReferenciaOrganigramaMap()
        {
            //table
            ToTable("GeoReferenciaOrganigramas");

            //pk
            HasKey(t => t.Id);

            //property
            Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);


            HasRequired(t => t.GeoReferencia)
                .WithMany(c => c.GeoReferenciaOrganigramas)
                .HasForeignKey(t => t.GeoReferenciaId)
                .WillCascadeOnDelete(false);

            HasRequired(t => t.Organigrama)
                .WithMany(c => c.GeoReferenciaOrganigramas)
                .HasForeignKey(t => t.OrganigramaId)
                .WillCascadeOnDelete(false);


        }
    }
}
